﻿/* ***********************************************
 * Author		:  kingthy
 * Email		:  kingthy@gmail.com
 * Description	:  TweetSummary
 *
 * ***********************************************/

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace OpenTwitter.SDK.Sina.Objects
{
    /// <summary>
    /// 微博的摘要数据
    /// </summary>
    public class TweetSummary
        : ResponseObject
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="xml"></param>
        internal TweetSummary(XmlNode xml)
            : base(xml)
        { }
        /// <summary>
        /// 微博id
        /// </summary>
        public long Id { get; private set; }

        /// <summary>
        /// 微博mid
        /// </summary>
        public long Mid { get; private set; }
        /// <summary>
        /// 微博内容
        /// </summary>
        public string Text { get; private set; }
        /// <summary>
        /// 来源
        /// </summary>
        public string Source { get; private set; }
        /// <summary>
        /// 发表时间
        /// </summary>
        public DateTime CreatedAt { get; private set; }
        /// <summary>
        /// 是否收藏
        /// </summary>
        public bool Favorited { get; private set; }
        /// <summary>
        /// 
        /// </summary>
        public bool Truncated { get; private set; }
        /// <summary>
        /// 地理位置信息
        /// </summary>
        public string Geo { get; private set; }
        /// <summary>
        /// 回复的微博Id
        /// </summary>
        public long ReplyToTweetId { get; private set; }
        /// <summary>
        /// 回复人的Id
        /// </summary>
        public long ReplyToUserId { get; private set; }
        /// <summary>
        /// 回复人的名称
        /// </summary>
        public string ReplyToUserName { get; private set; }
        /// <summary>
        /// 附加图片的缩略图地址
        /// </summary>
        public string ThumbnailPicture { get; private set; }
        /// <summary>
        /// 附加图片的中图地址
        /// </summary>
        public string BMiddlePicture { get; private set; }
        /// <summary>
        /// 附加图片的源图地址
        /// </summary>
        public string OriginalPicture { get; private set; }

        /// <summary>
        /// 解析XML数据
        /// </summary>
        protected override void Parse()
        {
            this.Id = Util.GetXmlNodeValue<long>(this.Xml.SelectSingleNode("id"));
            this.Mid = Util.GetXmlNodeValue<long>(this.Xml.SelectSingleNode("mid"));
            this.Text = Util.GetXmlNodeValue<string>(this.Xml.SelectSingleNode("text"));
            this.Source = Util.GetXmlNodeValue<string>(this.Xml.SelectSingleNode("source"));
            this.CreatedAt = Util.ConvertSinaTime(Util.GetXmlNodeValue<string>(this.Xml.SelectSingleNode("created_at")));
            this.Favorited = Util.GetXmlNodeValue<bool>(this.Xml.SelectSingleNode("favorited"));
            this.Truncated = Util.GetXmlNodeValue<bool>(this.Xml.SelectSingleNode("truncated"));
            this.Geo = Util.GetXmlNodeValue<string>(this.Xml.SelectSingleNode("geo"));
            this.ReplyToTweetId = Util.GetXmlNodeValue<long>(this.Xml.SelectSingleNode("in_reply_to_status_id"));
            this.ReplyToUserId = Util.GetXmlNodeValue<long>(this.Xml.SelectSingleNode("in_reply_to_user_id"));
            this.ReplyToUserName = Util.GetXmlNodeValue<string>(this.Xml.SelectSingleNode("in_reply_to_screen_name"));
            this.ThumbnailPicture = Util.GetXmlNodeValue<string>(this.Xml.SelectSingleNode("thumbnail_pic"));
            this.BMiddlePicture = Util.GetXmlNodeValue<string>(this.Xml.SelectSingleNode("bmiddle_pic"));
            this.OriginalPicture = Util.GetXmlNodeValue<string>(this.Xml.SelectSingleNode("original_pic"));
        }
    }
}
